/**
 * 
 */
package com.eagle.coders.security.beans;

import java.io.Serializable;
import java.util.List;

import javax.enterprise.inject.Model;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Transient;


import com.eagle.coders.common.bean.annotations.DomainTitle;
import com.eagle.coders.common.bean.annotations.Password;
import com.eagle.coders.common.bean.annotations.PropertyConstraints;
import com.eagle.coders.common.bean.annotations.RadioButton;
import com.eagle.coders.common.bean.annotations.RadioButtons;
import com.eagle.coders.common.bean.annotations.ResourceKey;
import com.eagle.coders.common.bean.annotations.TableColumn;
import com.eagle.coders.common.bean.annotations.TableColumns;
import com.eagle.coders.common.bean.annotations.TextArea;
import com.eagle.coders.common.bean.annotations.UiComponentPosition;
import com.eagle.coders.common.bean.annotations.UnBound;
import com.eagle.coders.common.bean.annotations.type.MandatoryType;
import com.eagle.coders.common.bean.annotations.type.StringInputCaseType;
import com.eagle.coders.common.bean.annotations.type.TextFiledInputDataType;
import com.eagle.coders.security.type.BankingSystemType;
import com.eagle.coders.security.type.UserTitlesEnum;


/**
 * @author Anees
 *
 */
@Entity
@Model
@Table(name="eagle_users")
@DomainTitle(title = "bean.user.title.UserInfo")
@SequenceGenerator(name = "user_gen_seq", sequenceName ="eagle_gen_seq")
public class UsersBean implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	private Integer id;
	
	private String userName;
	
	private String password;
	
	private String firstName;
	
	private String middleName;
	
	private String familyName;
	
	private List<AddressBean> address;
	
	private String phoneNumber;
	
	private String emailAddress;
	
	private UserTitlesEnum titles;
	
	private List<RanksBean> userRank;
	
	private List<RolesBean> userRoles;
	
	private Integer status;
	
	private BankingSystemType bankingSystemType;
	
	private Boolean isDefaultUserRole;
	
	private List<Object> menuList;
	
	

	/**
	 * @return the id
	 */
	
	@Id
	@ResourceKey(key="bean.user.id")
	@GeneratedValue(generator="user_gen_seq", strategy=GenerationType.SEQUENCE)
	@UiComponentPosition(positionColumn = "2", positionRow = "1", tableDisplayColumn= "1")
	public Integer getId() {
		return id;
	}

	/**
	 * @param id the id to set
	 */
	public void setId(Integer id) {
		this.id = id;
	}

	/**
	 * @return the userName
	 */
	@ResourceKey(key="bean.user.userName")
	@UiComponentPosition(positionColumn = "1", positionRow = "1", tableDisplayColumn= "1")
	@PropertyConstraints(isMandatory = MandatoryType.TURE, maxLength = "8", inputCaseType = StringInputCaseType.UPPERCASE, textInputDataType = TextFiledInputDataType.ONLYALPHA)
	@Column(name="userName", length=10, nullable=false, unique=true)
	public String getUserName() {
		return userName;
	}

	/**
	 * @param userName the userName to set
	 */
	public void setUserName(String userName) {
		this.userName = userName;
	}

	/**
	 * @return the password
	 */
	@ResourceKey(key="bean.user.password")
	@Password
	@Column(name = "password", length=10)
	@UiComponentPosition(positionColumn = "1", positionRow = "2", tableDisplayColumn= "1")
	public String getPassword() {
		return password;
	}

	/**
	 * @param password the password to set
	 */
	public void setPassword(String password) {
		this.password = password;
	}

	/**
	 * @return the firstName
	 */
	@ResourceKey(key="bean.user.firstName")
	@Column(name = "firstName", length=50)
	@UiComponentPosition(positionColumn = "1", positionRow = "4", tableDisplayColumn= "1")
	public String getFirstName() {
		return firstName;
	}

	/**
	 * @param firstName the firstName to set
	 */
	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}

	/**
	 * @return the middleName
	 */
	@ResourceKey(key="bean.user.userMiddleName")
	@Column(name = "middleName", length=5)
	@UiComponentPosition(positionColumn = "1", positionRow = "5", tableDisplayColumn= "1")
	public String getMiddleName() {
		return middleName;
	}

	/**
	 * @param middleName the middleName to set
	 */
	public void setMiddleName(String middleName) {
		this.middleName = middleName;
	}

	/**
	 * @return the familyName
	 */
	@ResourceKey(key="bean.user.familyName")
	@Column(name = "familyName", length=50)
	@UiComponentPosition(positionColumn = "2", positionRow = "5", tableDisplayColumn= "1")
	public String getFamilyName() {
		return familyName;
	}

	/**
	 * @param familyName the familyName to set
	 */
	public void setFamilyName(String familyName) {
		this.familyName = familyName;
	}

	/**
	 * @return the address
	 */
//	@Column(name = "addressCode")
	@ResourceKey(key="bean.user.address")
	@UiComponentPosition(positionColumn = "1", positionRow = "8")
	@ManyToMany(fetch=FetchType.LAZY, cascade=CascadeType.ALL, targetEntity=AddressBean.class)
	@JoinTable(name="eagle_addres_user", joinColumns={@JoinColumn(name = "userId", referencedColumnName="id")},
			inverseJoinColumns={@JoinColumn(name = "addressId", referencedColumnName="id")})
	public List<AddressBean> getAddress() {
		return address;
	}

	/**
	 * @param address the address to set
	 */
	public void setAddress(List<AddressBean> address) {
		this.address = address;
	}

	/**
	 * @return the phoneNumber
	 */
	@ResourceKey(key="bean.user.phoneNumber")
	@Column(name= "phoneNumber")
	@UiComponentPosition(positionColumn = "1", positionRow = "6")
	public String getPhoneNumber() {
		return phoneNumber;
	}

	/**
	 * @param phoneNumber the phoneNumber to set
	 */
	public void setPhoneNumber(String phoneNumber) {
		this.phoneNumber = phoneNumber;
	}

	/**
	 * @return the emailAddress
	 */
	@ResourceKey(key="bean.user.emailAddress")
	@Column(name = "emailAddress")
	@UiComponentPosition(positionColumn = "1", positionRow = "7")
	public String getEmailAddress() {
		return emailAddress;
	}

	/**
	 * @param emailAddress the emailAddress to set
	 */
	public void setEmailAddress(String emailAddress) {
		this.emailAddress = emailAddress;
	}

	/**
	 * @return the titles
	 */
	@ResourceKey(key="bean.user.title")
	@Column(name = "title")
	@Enumerated(EnumType.STRING)
	@UiComponentPosition(positionColumn = "1", positionRow = "3")
	public UserTitlesEnum getTitles() {
		return titles;
	}

	/**
	 * @param titles the titles to set
	 */
	public void setTitles(UserTitlesEnum titles) {
		this.titles = titles;
	}

	/**
	 * @return the userRank
	 */
	@ResourceKey(key="bean.user.ranks")
	@UiComponentPosition(positionColumn = "1", positionRow = "9")
	@TableColumns(tableColumn = {  @TableColumn(columnPosition = "2", property = "rank"),
			@TableColumn(columnPosition = "3", property = "description"), @TableColumn(columnPosition = "4", property = "rankId")})
	@ManyToMany(fetch=FetchType.LAZY, cascade = CascadeType.ALL, targetEntity = RanksBean.class)
	@JoinTable(name = "eagle_rank_user", joinColumns={@JoinColumn(name = "userId", referencedColumnName="id")},
			inverseJoinColumns= {@JoinColumn(name = "rankId", referencedColumnName="id")})
	public List<RanksBean> getUserRank() {
		return userRank;
	}

	/**
	 * @param userRank the userRank to set
	 */
	public void setUserRank(List<RanksBean> userRank) {
		this.userRank = userRank;
	}

	/**
	 * @return the userRoles
	 */
	@ResourceKey(key="bean.user.roles")
	@UiComponentPosition(positionColumn = "1", positionRow = "10")
	@ManyToMany(fetch=FetchType.LAZY, cascade = CascadeType.ALL, targetEntity=RolesBean.class)
	@JoinTable(name = "eagle_role_user", joinColumns={@JoinColumn(name = "userId", referencedColumnName="Id")},
			inverseJoinColumns= {@JoinColumn(name = "roleId", referencedColumnName="id")})
	public List<RolesBean> getUserRoles() {
		return userRoles;
	}

	/**
	 * @param userRoles the userRoles to set
	 */
	public void setUserRoles(List<RolesBean> userRoles) {
		this.userRoles = userRoles;
	}

	/**
	 * @return the status
	 */
//	@Column(name = "status")
	@Transient
	public Integer getStatus() {
		return status;
	}

	/**
	 * @param status the status to set
	 */
	public void setStatus(Integer status) {
		this.status = status;
	}

	/**
	 * @return the bankingSystemType
	 */
	@ResourceKey(key="bean.user.bankType")
	@Transient
	@Enumerated(EnumType.STRING)
	@UiComponentPosition(positionColumn = "1", positionRow = "20")
	public BankingSystemType getBankingSystemType() {
		return bankingSystemType;
	}

	/**
	 * @param bankingSystemType the bankingSystemType to set
	 */
	public void setBankingSystemType(BankingSystemType bankingSystemType) {
		this.bankingSystemType = bankingSystemType;
	}

	/**
	 * @return the isDefaultUserRole
	 */
	@ResourceKey(key="bean.user.roleDefault")
	@Transient
	@UiComponentPosition(positionColumn = "1", positionRow = "21")
	public Boolean getIsDefaultUserRole() {
		return isDefaultUserRole;
	}

	/**
	 * @param isDefaultUserRole the isDefaultUserRole to set
	 */
	public void setIsDefaultUserRole(Boolean isDefaultUserRole) {
		this.isDefaultUserRole = isDefaultUserRole;
	}

	/**
	 * @return the menuList
	 */
	@UnBound
	@Transient
	public List<Object> getMenuList() {
		return menuList;
	}

	/**
	 * @param menuList the menuList to set
	 */
	public void setMenuList(List<Object> menuList) {
		this.menuList = menuList;
	}
	
	
}